﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace PrattParsing
{
    [DebuggerNonUserCode]
    public class ParseContext<E>
    {
        ParseletMap<PrefixParselet<E>> prefixParselets;
        ParseletMap<InfixParselet<E>> infixParselets;

        public ParseContext()
        {
            prefixParselets = new ParseletMap<PrefixParselet<E>>(null);
            infixParselets = new ParseletMap<InfixParselet<E>>(null);
        }
        public ParseContext(ParseletMap<PrefixParselet<E>> prefixParselets,
            ParseletMap<InfixParselet<E>> infixParselets)
        {
            prefixParselets = prefixParselets;
            infixParselets = infixParselets;
        }

        public void prefix(TokenMatch match, PrefixParselet<E> parselet)
        {
            prefixParselets.set(match, parselet);
        }
        public void infix(TokenMatch match, InfixParselet<E> parselet)
        {
            infixParselets.set(match, parselet);
        }

        public ParseletMap<PrefixParselet<E>> prefixMap()
        {
            return prefixParselets;
        }
        public ParseletMap<InfixParselet<E>> infixMap()
        {
            return infixParselets;
        }
    }
}
